/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.ocr.mpp;

import com.sun.javafx.scene.control.skin.VirtualFlow;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Austin
 */
public class test {

    public static void main(String[] args) {
        String o = "[{\"aeskey\":\"2a286ae85169462b80546bd422ba847d\",\"fileid\":\"3050020100044930470201000204fe43fa4502032dd14f02049a36fcb7020459e2a42e0422363936313730303235374063686174726f6f6d313637385f313530383032353338390204010800020201000400\"}]";
        List<String> list= new ArrayList<>();
        list.add(o.substring(1,o.length()-1));
        System.out.println(listFormat(list));
    }

    private static <T> String arrayFormat(T[] list) {
        if (list == null || list.length == 0) {
            return null;
        }
        if (list[0].getClass() == String.class) {
            String res = "[";
            for (int i = 0; i < list.length; ++i) {
                if (i > 0) {
                    res += ",";
                }
                res += "'" + list[i].toString() + "'";
            }
            return res + "]";
        } else if (list[0].getClass() == int.class || list[0].getClass() == long.class
                || list[0].getClass() == Integer.class || list[0].getClass() == Long.class) {
            String res = "[";
            for (int i = 0; i < list.length; ++i) {
                if (i > 0) {
                    res += ",";
                }
                res += list[i].toString();
            }
            return res + "]";
        }
        return null;
    }

    private static <T> String listFormat(List<T> list) {
        return arrayFormat(list.toArray());
    }
}
